package com.tensai.teach.魔方;

import com.tensai.study.基础.算法.矩阵快速幂.Main;
import lombok.Data;

/**
 * @author Tensai
 */
@Data
public class Base {
    Color color;
    Type type;
    Mian mian;
    int x;
    int y;

    /**
     * 初始化调用
     *
     * @param color
     * @param x
     * @param y
     */
    public Base(Color color, int x, int y) {
        this.color = color;
        boolean b = checkType(x, y);
        if (!b) {
            System.out.println();
        }
        this.x = x;
        this.y = y;
    }

    private void checkMain(Color color) {
        switch (color) {
            case RED:       this.mian = Mian.RIGHT; break;
            case BLUE:      this.mian = Mian.FRONT; break;
            case GREEN:     this.mian = Mian.BACK;  break;
            case WHITE:     this.mian = Mian.DOWN;  break;
            case ORANGE:    this.mian = Mian.LEFT;  break;
            case YELLOW:    this.mian = Mian.UP;    break;
            default:                                break;
        }
    }

    private boolean checkType(int x, int y) {
        if (this.type == null) {
            this.type = guessType(x, y);
            return true;
        } else {
            return this.type == guessType(x, y);
        }
    }

    private Type guessType(int x, int y) {
        Type type;
        if (x == 1 && y == 1) {
            type = Type.C;
            return type;
        }
        if (x + y == 1 || x + y == 3) {
            type = Type.B;
        } else {
            type = Type.J;
        }
        return type;
    }
}
